package com.ai.dmc.index.web.action;


import java.io.InputStream;

import com.ai.dmc.index.common.InitParam;
import com.ai.dmc.index.common.bean.StaffSessBean;
import com.ai.dmc.index.web.util.SessionInfoUtil;
import com.ai.frame.bean.InputObject;
import com.ai.frame.bean.OutputObject;
import com.ai.frame.logger.Logger;
import com.ai.frame.logger.LoggerFactory;
import com.ai.frame.util.ConvertUtil;
import com.ai.frame.util.JsonUtil;

/**
 */
public class CommonAction extends BaseAction {
	private static final long serialVersionUID = 2021751417577646314L;
	private static final Logger logger = LoggerFactory.getActionLog(CommonAction.class);
	
	
	private StaffSessBean session;
	private String userId;
	private boolean isAdmin;
	private String areaId;
	/**
	 * 
	 * @Description : 初始化
	 * @return void
	 * 
	 * @author : wucm
	 * @date : 2015年7月10日 上午9:41:28
	 * 
	 */
	public void init() {
		session = SessionInfoUtil.getStaffSessBean(
				this.getRequest().getSession());
		userId = session.getUserId();
		isAdmin = session.isAdmin();
		areaId = session.getAreaId();
	}
	
	/** Uniform Method Invocation **/
	public String execute() {
		logger.info("execute", "Start");
		this.init();
		InputObject inputObject = super.getInputObject();
		inputObject.getParams().put("userId", userId);
		inputObject.getParams().put("isAdmin", String.valueOf(isAdmin));
		inputObject.getParams().put("areaId", areaId);
		OutputObject object = super.getOutputObject();
		super.sendJson(super.convertOutputObject2Json(object));
		logger.info("execute", "End");
		return null;
	}
	
//	public void importance() {
//		InputObject inputObject = getInputObject();
//		System.out.println(JsonUtil.inputObject2Json(inputObject));
//		String str = inputObject.getParams().get("fileData");
//		System.out.println(str);
//		InputStream inputStream = ConvertUtil.string2InputStream(str);
//		System.out.println(inputStream);
//		
//	}
//	public String importance() {
//		logger.info("importance", "Start");
////		InputObject inputObject = getInputObject();
////		System.out.println(JsonUtil.inputObject2Json(inputObject));
////		String str = inputObject.getParams().get("fileData");
////		System.out.println(str);
////		OutputObject object1 = super.getOutputObject(inputObject);
////		super.sendJson(super.convertOutputObject2Json(object1));
//		//InputStream inputStream = ConvertUtil.string2InputStream(str);
//		OutputObject object = super.getOutputObject();
//		super.sendJson(super.convertOutputObject2Json(object));
//		logger.info("importance", "End");
//		return null;
//	}
}
